﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;
using COFE.Core.Profile;
using COFE.Core.Utils;

namespace COFE.Core.Entry
{
    /// <summary>
    /// Used for construct secondary property providers, call UserProfile.Register() to register the factory.
    /// </summary>
    public interface ISecondaryPropertyProvider<T> 
    {
        object[] GetSupportedProperty(T sourceObj);
        bool IsPropertyReadOnly(T sourceObj, object property);
        PropertyPair GetProperty(T sourceObj, object property);
        void SetProperty(T sourceObj, object property, object value);
    }

    public static class ISecondaryPropertyProviderExtension
    {
        public static bool IsPropertySupported<T>(this ISecondaryPropertyProvider<T> provider, T sourceObj, object property)
        {
            return provider.GetSupportedProperty(sourceObj).Contains(property);
        }
    }
}
